package cn.edu.cdtu.yulei.test_demo.controller;

import cn.edu.cdtu.yulei.test_demo.service.impl.InterfaceInfoImpl;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/cookies.do")
public class GetCookies extends HttpServlet {
    /**
     * 获取cookies信息
     * @param req
     * @param resp
     */
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp){
        Cookie[] cookies = req.getCookies();
        for (Cookie cookie : cookies) {
            System.out.println("name:" + cookie.getName() + "\n" + "version:" + cookie.getVersion() + "\n" +
                    "value:" + cookie.getValue() + "\n" + "secure:" + cookie.getSecure() + "\n" +
                    "path:" + cookie.getPath() + "\n" + "maxAge:" +  cookie.getMaxAge() + "\n" +
                    "domain:" + cookie.getDomain() + "\n" + "comment:" + cookie.getComment() + "\n");
        }
        InterfaceInfoImpl interfaceInfo = new InterfaceInfoImpl();
        interfaceInfo.addInterfaceInfo("/commService/cookies.do");
    }
}
